package com.nbsaas.boot.product.rest.resource;

import com.nbsaas.boot.product.api.apis.ProductImageApi;
import com.nbsaas.boot.product.data.entity.ProductImage;
import com.nbsaas.boot.product.api.domain.request.ProductImageRequest;
import com.nbsaas.boot.product.api.domain.response.ProductImageResponse;
import com.nbsaas.boot.product.api.domain.simple.ProductImageSimple;
import com.nbsaas.boot.product.rest.convert.ProductImageSimpleConvert;
import com.nbsaas.boot.product.rest.convert.ProductImageEntityConvert;
import com.nbsaas.boot.product.rest.convert.ProductImageResponseConvert;
import com.nbsaas.boot.product.data.repository.ProductImageRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   商品图片-业务接口实现
*/
@Transactional
@Service
public class ProductImageResource extends BaseResource<ProductImage,ProductImageResponse, ProductImageSimple, ProductImageRequest>  implements ProductImageApi {

    @Resource
    private ProductImageRepository productImageRepository;

    @Override
    public JpaRepositoryImplementation<ProductImage, Serializable> getJpaRepository() {
        return productImageRepository;
    }

    @Override
    public Function<ProductImage, ProductImageSimple> getConvertSimple() {
        return new ProductImageSimpleConvert();
    }

    @Override
    public Function<ProductImageRequest, ProductImage> getConvertForm() {
        return new ProductImageEntityConvert();
    }

    @Override
    public Function<ProductImage, ProductImageResponse> getConvertResponse() {
        return new ProductImageResponseConvert();
    }




}


